/**
 * @file 应用主模块
 * @description 注册全局模块和配置
 * @author Assistant
 * @date 2024-02-05
 */

import { Module } from '@nestjs/common';
import { HttpModule } from '@nestjs/axios';
import { ConfigModule } from '@nestjs/config';
import { TrackModule } from './modules/track/track.module';
import { LoggerModule } from './common/modules/logger.module';
import { AppController } from './app.controller';
import { TrackService } from './modules/track/services/track.service';
import { MongooseModule } from '@nestjs/mongoose';
import { mongoConfig } from './config/database.config';

@Module({
  imports: [
    ConfigModule.forRoot({
      envFilePath: '.env',
      isGlobal: true
    }),
    HttpModule,
    LoggerModule,
    TrackModule,
    MongooseModule.forRoot(mongoConfig().uri, {
      maxPoolSize: 5,
      minPoolSize: 1,
      connectTimeoutMS: 5000,
      socketTimeoutMS: 30000,
      retryWrites: true,
      retryReads: true,
      heartbeatFrequencyMS: 30000,
      autoIndex: true,
      autoCreate: true,
    }),
  ],
  controllers: [AppController],
  providers: [TrackService],
})
export class AppModule {} 